const koa = require('koa')
const bodyParser = require('koa-bodyparser')

const { errHandler } = require('./err_handle')
const useRoutes = require('../router/index')

const app = new koa()
app.useRoutes = useRoutes

app.use(bodyParser())
app.useRoutes()

// 错误处理中间件
app.on('error', errHandler)

module.exports = app
